.w-tooltip-wrap {
  display: none;

  &--attached {
    display: inline-block;
    position: relative;
  }
}

.w-tooltip {
  // Fix Safari where `width: max-content` does not take padding and border into consideration.
  display: table;

  position: absolute;
  padding: $base-increment round(1.5 * $base-increment);
  border-radius: $border-radius;
  border: 1px solid #ddd;
  background-color: $tooltip-bg-color;
  pointer-events: none;
  color: $tooltip-color;
  align-items: center;
  max-width: 300px;
  width: max-content; // Not supported in IE11. :/

  &--fixed {
    position: fixed;
    z-index: 1000;
  }

  &--tile {
    border-radius: 0;
  }
  &--round {
    border-radius: 9em;
    padding: $base-increment round(2.5 * $base-increment);
  }
  &--shadow {
    box-shadow: $box-shadow;
  }
  &--no-border {
    border: none;
  }

  &--top {
    transform: translate(-50%, -100%);
    margin-top: -3 * $base-increment;
  }
  &--bottom {
    transform: translateX(-50%);
    margin-top: 3 * $base-increment;
  }
  &--left {
    transform: translate(-100%, -50%);
    margin-left: -3 * $base-increment;
  }
  &--right {
    transform: translateY(-50%);
    margin-left: 3 * $base-increment;
  }

  &--custom-transition {
    transform: none;
  }

  &:after {
    content: "";
    position: absolute;
    width: 0;
    height: 0;
    border: 6px solid transparent;
  }
  &--top:after {
    top: 100%;
    left: 50%;
    border-top-color: $tooltip-bg-color;
    transform: translateX(-50%);
    margin-top: 1px;
  }
  &--bottom:after {
    bottom: 100%;
    left: 50%;
    border-bottom-color: $tooltip-bg-color;
    transform: translateX(-50%);
    margin-bottom: 1px;
  }
  &--left:after {
    left: 100%;
    top: 50%;
    border-left-color: $tooltip-bg-color;
    transform: translateY(-50%);
    margin-left: 1px;
  }
  &--right:after {
    right: 100%;
    top: 50%;
    border-right-color: $tooltip-bg-color;
    transform: translateY(-50%);
    margin-right: 1px;
  }

  // Tooltip without border.
  // --------------------------------------------------------
  &--no-border.w-tooltip--top:after {
    margin-top: -1px;
    border-top-color: inherit;
  }
  &--no-border.w-tooltip--bottom:after {
    margin-bottom: -1px;
    border-bottom-color: inherit;
  }
  &--no-border.w-tooltip--left:after {
    margin-left: -1px;
    border-left-color: inherit;
  }
  &--no-border.w-tooltip--right:after {
    margin-right: -1px;
    border-right-color: inherit;
  }

  // Tooltip with border.
  // --------------------------------------------------------
  &:not(&--no-border).w-tooltip--top:after {
    margin-top: -1px;
  }
  &:not(&--no-border).w-tooltip--bottom:after {
    margin-bottom: -1px;
  }
  &:not(&--no-border).w-tooltip--left:after {
    margin-left: -1px;
  }
  &:not(&--no-border).w-tooltip--right:after {
    margin-right: -1px;
  }

  &:not(&--no-border) {
    &:before {
      content: "";
      position: absolute;
      width: 0;
      height: 0;
      border: 7px solid transparent;
    }
    &.w-tooltip--top:before {
      top: 100%;
      left: 50%;
      border-top-color: inherit;
      transform: translateX(-50%);
      margin-top: 0;
    }
    &.w-tooltip--bottom:before {
      bottom: 100%;
      left: 50%;
      border-bottom-color: inherit;
      transform: translateX(-50%);
      margin-bottom: 0;
    }
    &.w-tooltip--left:before {
      left: 100%;
      top: 50%;
      border-left-color: inherit;
      transform: translateY(-50%);
      margin-left: 0;
    }
    &.w-tooltip--right:before {
      right: 100%;
      top: 50%;
      border-right-color: inherit;
      transform: translateY(-50%);
      margin-right: 0;
    }
  }
  // --------------------------------------------------------
}

// Transitions.
// --------------------------------------------------------
.w-tooltip-slide-fade-up-enter-active,
.w-tooltip-slide-fade-up-leave-active,
.w-tooltip-slide-fade-down-enter-active,
.w-tooltip-slide-fade-down-leave-active,
.w-tooltip-slide-fade-left-enter-active,
.w-tooltip-slide-fade-left-leave-active,
.w-tooltip-slide-fade-right-enter-active,
.w-tooltip-slide-fade-right-leave-active {
  transition: margin $transition-duration ease-in-out,
    opacity $transition-duration ease-in-out;
}

// slide-fade-up.
.w-tooltip-slide-fade-up-enter-from,
.w-tooltip-slide-fade-up-leave-to {
  margin-top: -2 * $base-increment;
  opacity: 0;
}

// slide-fade-down.
.w-tooltip-slide-fade-down-enter-from,
.w-tooltip-slide-fade-down-leave-to {
  margin-top: 2 * $base-increment;
  opacity: 0;
}

// Slide-fade-left.
.w-tooltip-slide-fade-left-enter-from,
.w-tooltip-slide-fade-left-leave-to {
  margin-left: -2 * $base-increment;
  opacity: 0;
}

// Slide-fade-right.
.w-tooltip-slide-fade-right-enter-from,
.w-tooltip-slide-fade-right-leave-to {
  margin-left: 2 * $base-increment;
  opacity: 0;
}
// --------------------------------------------------------
